home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / PROCTYPE.MOD < prev    next >
Text File  |  1989-01-18  |  2KB  |  60 lines

  1.                                        (* Chapter 13 - Program 10 *)
  2. MODULE ProcType;
  3.  
  4. FROM InOut IMPORT WriteString, WriteLn;
  5.  
  6. VAR OutputStuff : PROCEDURE(ARRAY OF CHAR);
  7.     VarLine     : ARRAY[0..50] OF CHAR;
  8.  
  9.      PROCEDURE WriteWithNote(InString : ARRAY OF CHAR);
  10.      BEGIN
  11.         WriteString("Written with a note ---> ");
  12.         WriteString(InString);
  13.         WriteLn;
  14.      END WriteWithNote;
  15.  
  16.      PROCEDURE WriteWithComment(InputLine : ARRAY OF CHAR);
  17.      BEGIN
  18.         WriteString(InputLine);
  19.         WriteString(" <--- Written with a comment");
  20.         WriteLn;
  21.      END WriteWithComment;
  22.  
  23. BEGIN
  24.    VarLine := "This is a line of data.";
  25.                                         (* This uses WriteWithNote *)
  26.    OutputStuff := WriteWithNote;
  27.    OutputStuff(VarLine);
  28.    OutputStuff("Extra output ");
  29.                                       (* This uses WiteWithComment *)
  30.    OutputStuff := WriteWithComment;
  31.    OutputStuff(VarLine);
  32.                                           (* This uses WriteString *)
  33.    OutputStuff := WriteString;
  34.    OutputStuff(VarLine);
  35.    OutputStuff(" End of the line");
  36.    WriteLn;
  37.                (* The Procedures can be used in normal fashion too *)
  38.    WriteLn;
  39.    WriteWithNote("This is straight output.");
  40.    WriteWithComment("This too is straight output.");
  41.    WriteString(VarLine);
  42. END ProcType.
  43.  
  44.  
  45.  
  46.  
  47. (* Result of execution
  48.  
  49. Written with a note ---> This is a line of data.
  50. Written with a note ---> Extra output
  51. This is a line of data. <--- Written with a comment
  52. This is a line of data. End of the line
  53.  
  54. Written with a note ---> This is straight output.
  55. This too is straight output. <--- Written with a comment
  56. This is a line of data.
  57.  
  58. *)
  59.  
  60.